
package com.example.com.baruffini_mele.booking4u;

import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.TextView;

public class HelpActivity extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_help_layout);
        
        TextView helpTxt = (TextView)findViewById(R.id.help_text);
        helpTxt.setText(readTxt());
       
    }

    private String readTxt(){
    	
    	
        InputStream inputStream = getResources().openRawResource(R.raw.help_text);
        
        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
        
        int i;
     try {
      i = inputStream.read();
      while (i != -1)
         {
          byteArrayOutputStream.write(i);
          i = inputStream.read();
         }
         inputStream.close();
         
        
         
     } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
     }
     
     
     
        return byteArrayOutputStream.toString();
     
       }
    
    
    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_help_menu, menu);
        return(super.onCreateOptionsMenu(menu));
    }
    
    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) 
        {
        	// if help selected
            case R.id.help_menu_home:
            	// start Main
               startActivity(new Intent(this, MainActivity.class));
            return true;
            
            
        }// end switch on menu item
        return(super.onOptionsItemSelected(item));
    }
    
    
} 
    
    
    

